/*
 * @Author: ygnnli 1585923072@qq.com
 * @Date: 2024-08-24 16:05:11
 * @LastEditors: ygnnli 1585923072@qq.com
 * @LastEditTime: 2024-08-24 17:28:42
 * @FilePath: /boost_searcher/server.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "searcher.hpp"
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>

const std::string input = "data/raw_html/raw.txt";

int main()
{
    ns_searcher::Searcher *search = new ns_searcher::Searcher();
    search->InitSearcher(input);

    std::string query;
    std::string json_string;
    char buffer[1024];
    while(true)
    {
        std::cout<<"Please Enter You Search Query# ";
        //std::cin>>query; // aa bb cc 分开输入了
        fgets(buffer, sizeof(buffer) - 1, stdin);
        buffer[strlen(buffer) - 1] = 0;//去掉换行符
        query = buffer;
        
        search->Search(query, &json_string);
        
        std::cout<<json_string<<std::endl;
    }

    return 0;
}